package ee.falcon.gui.frame;

import java.util.Map;

import javax.swing.DefaultListModel;

import ee.falcon.xml.SpecificProfileInfo;

public class ProfilesFrameJListEditor 
{
	private Map<String, SpecificProfileInfo> profileInfoHashMap; 
	private DefaultListModel defaultListModel; 
	
	public ProfilesFrameJListEditor(DefaultListModel defaultListModel, Map<String, SpecificProfileInfo> profileInfoHashMap) 
	{
		this.defaultListModel = defaultListModel;
		this.profileInfoHashMap = profileInfoHashMap; 
	}
	
	public void renewJListData()
	{
		//Removing old JList elements
		defaultListModel.removeAllElements(); 
		for (Map.Entry<String, SpecificProfileInfo> entry : profileInfoHashMap.entrySet())
		{
			String key = entry.getKey(); 
			SpecificProfileInfo value = entry.getValue(); 
			defaultListModel.addElement(value); //elements to JList
			System.out.println("key= "+ key + ", value = " + value);  
		} 
	}
	
	public void initializeJListProfilesData()
	{
		for (Map.Entry<String, SpecificProfileInfo> entry : profileInfoHashMap.entrySet())
		{
			String key = entry.getKey(); 
			SpecificProfileInfo value = entry.getValue();
			defaultListModel.addElement(value); //adding elements to JList
			System.out.println("key= "+ key + ", value = " + value);  
		} 
	}
}
